*sigh*, been doing this all day, error number 2 is killing me.
Code:
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
int main()
{
char cISBN[10];
int i,iLen,iNNF,iISBN[9],iTotal;
for(i=0;i<10;i++)
{
cISBN[i]='\0';
}
printf("Enter ISBN to calculate Check Digit ");
gets(cISBN);
iLen=strlen(cISBN);
if(iLen!=9)
{
printf("ISBN length error ");
}
else
{
iNNF=0;
for(i=0;i<iLen&&iNNF==0;i++)
{
if((cISBN[i]<0)||(cISBN[i]>9))
{
printf("ISBN numerical error ");
iNNF=1;
}
else
{
iISBN[i]=cISBN[i]-48;
iTotal+=iISBN[i]*(i+1);
}
}
}
printf("%d",(iTotal%11));
getch();
return 0;
}
/*something is wrong in BOLD, the output is either "ISBN numerical error 10" or "ISBN length error 10" and I don't know what the hell the 10 is...*/
iNNF is Non-Numerical Flag.